package observer;

import java.util.ArrayList;

/**
 * 生成数值抽象类
 */
public abstract class NumberGenerator {
    private final ArrayList<Observer> observers = new ArrayList<>();

    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    public void delObserver(Observer observer) {
        observers.remove(observer);
    }

    /**
     * 通知观察者
     */
    public void notifyObservers(){
        for(Observer observer:observers){
            observer.update(this);
        }
    }
    public abstract int getNumber();
    public abstract void execute();


}
